home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / util / misc / gadmget1_5.lha / GadMget1.5 / Source / mget_listview2.c < prev    next >
C/C++ Source or Header  |  1994-10-01  |  14KB  |  576 lines

  1. #ifndef MGET_LISTVIEW2_C
  2. #define MGET_LISTVIEW2_C
  3.  
  4. /*
  5.  *  Source machine generated by GadToolsBox V2.0b
  6.  *  which is (c) Copyright 1991-1993 Jaba Development
  7.  *
  8.  *  GUI Designed by : Jeremy Friesner
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/libraries.h>
  13. #include <intuition/intuition.h>g
  14. #include <intuition/classes.h>
  15. #include <intuition/classusr.h>
  16. #include <intuition/imageclass.h>
  17. #include <intuition/gadgetclass.h>
  18. #include <libraries/gadtools.h>
  19. #include <graphics/displayinfo.h>
  20. #include <graphics/gfxbase.h>
  21. #include <clib/exec_protos.h>
  22. #include <clib/intuition_protos.h>
  23. #include <clib/gadtools_protos.h>
  24. #include <clib/graphics_protos.h>
  25. #include <clib/utility_protos.h>
  26. #include <clib/wb_protos.h>
  27.  
  28. #include <workbench/workbench.h>
  29. #include <workbench/startup.h>
  30. #include <string.h>
  31.  
  32. #include "mget_listview2.h"
  33. #include "Gadmget.h"
  34.  
  35. extern char pnamestring[];
  36. extern struct List *filelist;
  37. extern struct List *getlist;
  38. extern struct Gadget *findgadlist;
  39. extern void *findvi;
  40. extern int appwindow;
  41. extern char *pubscreenname;
  42. extern int screentype;
  43. extern UWORD windowwidth;
  44. extern UWORD windowheight;
  45. extern UWORD windowtop;
  46. extern UWORD windowleft;
  47. extern char windowtitle[];
  48. extern int windowisopen;
  49. extern int screenisopen;
  50. extern char sListFontName[];
  51. extern int nListFontSize;
  52. int screenwidth,screenheight;
  53. extern FILE *fpOut;
  54. extern struct TextFont *listfontdata;  /* pointer to font data */
  55. extern struct GfxBase *GraphicsBase;        /* needed to determine default system font */
  56. extern BOOL BStartedFromWB;
  57. extern int nTopListTop;
  58. extern int nTopListHeight;
  59.     
  60.  
  61. struct Screen        *Scr = NULL;
  62. APTR                 VisualInfo = NULL;
  63. struct Window        *mgetWnd = NULL;
  64. struct Window            *findwindow = NULL;
  65. struct AppWindow        *appwin = NULL;
  66. struct AppMessage        *amsg = NULL;
  67. struct MsgPort         *awport = NULL;
  68. struct Gadget        *mgetGList = NULL;
  69. struct Menu          *mgetMenus = NULL;
  70. struct IntuiMessage  mgetMsg;
  71. struct Gadget        *mgetGadgets[2];
  72. UWORD                mgetLeft = 0;
  73. UWORD                mgetTop = 12;
  74. UWORD lastcode;
  75. ULONG appwinsig = 0L;
  76.  
  77. struct TextAttr topaz8 = {
  78.     ( STRPTR )"topaz.font", 8, 0x00, 0x00 };
  79.  
  80. struct TextAttr listfont = {
  81.     ( STRPTR )"topaz.font", 8 , 0x00, 0x00 };
  82.  
  83. struct NewMenu mgetNewMenu[] = {
  84. /* 0  */    NM_TITLE, (STRPTR)"Project", NULL, 0L, NULL, NULL,
  85. /* 1  */    NM_ITEM, (STRPTR)"Open", (STRPTR)"O", 0, 0L, (APTR)mgetopenfile,
  86. /* 2  */  NM_ITEM, (STRPTR)"Append", (STRPTR)"A", 0, 0L, (APTR) mgetappend,
  87. /* 3  */    NM_ITEM, (STRPTR)"About", NULL, 0, 0L, (APTR)mgetabout,
  88. /* 4  */    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0L, 0L, NULL,
  89. /* 5  */    NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, (APTR)mgetquit,
  90. /* 6  */    NM_TITLE, (STRPTR)"Search", NULL, 0L, NULL, NULL,
  91. /* 7  */    NM_ITEM, (STRPTR)"Find", (STRPTR)"F", 0, 0L, (APTR)mgetfind,
  92. /* 8  */    NM_ITEM, (STRPTR)"Find Next", (STRPTR)"N", 0, 0L, (APTR)mgetfindnext,
  93. /* 9  */    NM_ITEM, (STRPTR)"Case Sensitive", (STRPTR)"C", 0|CHECKIT, 0L, (APTR)mgetcase,
  94. /* 10  */    NM_TITLE, (STRPTR)"Output", NULL, 0L, NULL, NULL,
  95. /* 11 */    NM_ITEM, (STRPTR)"Aminet Parse", NULL, 0|CHECKIT, 0L, (APTR)mgetnoparse,
  96. /* 12 */    NM_ITEM, (STRPTR)"Get Files", NULL, 0|CHECKIT, 0L, (APTR)mgetfiles,
  97. /* 13 */    NM_ITEM, (STRPTR)"Get Readmes", NULL, 0|CHECKIT, 0L, (APTR)mgetreadmes,
  98. /* 14 */    NM_ITEM, (STRPTR)"Split Commands", NULL, 0|CHECKIT, 0L, (APTR)mgetsplit,
  99. /* 15 */ NM_ITEM, (STRPTR)"Simple Paths", NULL, 0|CHECKIT, 0L, (APTR)mgetCD,
  100. /* 16 */    NM_ITEM, (STRPTR)"Line Length...", (STRPTR)"L", 0, 0L, (APTR)mgetlinelength,
  101. /* 17 */    NM_END, NULL, NULL, 0, 0L, NULL };
  102.  
  103. char GadgetTextString0[] = "";
  104.  
  105. struct NewGadget mgetNGad[] = {
  106.     0, 0, 0, 0, (UBYTE *)"Selectable Files", NULL, 0, PLACETEXT_ABOVE, NULL, (APTR)listviewgadgetClicked,
  107.     0, 0, 0, 0, (UBYTE *)"Selected Files",   NULL, 1, PLACETEXT_BELOW, NULL, (APTR)list2Clicked
  108. };
  109.  
  110. ULONG mgetGTags[] = {
  111.     (GT_Underscore), '_', 
  112.     (TAG_DONE)
  113. };
  114.  
  115. UWORD DriPens[] = {
  116.     ~0 };
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. int SetupScreen( void )
  124. {
  125. ULONG lflag = 0L;
  126. struct Screen *sTemp = NULL;
  127. struct DrawInfo *screen_drawinfo = NULL;
  128.     
  129.     Scr = NULL;
  130.         
  131.     switch (screentype)
  132.         {
  133.         case USE_PUBSCREEN:
  134.             Scr = LockPubScreen(pubscreenname);
  135.             if (Scr == NULL)
  136.                 {
  137.                 MakeReq("Couldn't lock public screen!",NULL,"Huh?"); 
  138.                 return(1L);
  139.                 }
  140.             screenwidth     = Scr->Width;
  141.             screenheight    = Scr->Height;
  142.             break;
  143.             
  144.         case USE_CUSTOMSCREEN:
  145.          if ((sTemp = LockPubScreen("Workbench")) != NULL)
  146.             {
  147.             lflag = GetVPModeID(&(sTemp->ViewPort));    
  148.             screenwidth  = sTemp->Width;
  149.             screenheight = sTemp->Height;
  150.             }
  151.             else
  152.             {
  153.             screenwidth  = 640;
  154.             screenheight = 400;
  155.             lflag = HIRESLACE_KEY;
  156.             }
  157.            
  158.          if (sTemp != NULL) UnlockPubScreen(NULL,sTemp);
  159.             
  160.          if ( ! ( Scr = OpenScreenTags(NULL, 
  161.                          SA_Left,            0,
  162.                         SA_Top,            0,
  163.                         SA_Width,        screenwidth,
  164.                         SA_Height,        screenheight,
  165.                         SA_Depth,        2,
  166.                         SA_Font,            &GraphicsBase->DefaultFont,
  167.                         SA_Type,            CUSTOMSCREEN,
  168.                         SA_DisplayID,    lflag,
  169.                         SA_AutoScroll,    TRUE,
  170.                         SA_Overscan,    OSCAN_TEXT,
  171.                         SA_Pens,            &DriPens[0],
  172.                         SA_Title,        pnamestring,
  173.                         TAG_DONE ))) 
  174.                                 return( 1L );
  175.             break;
  176.             
  177.         case USE_WBSCREEN:
  178.             Scr = LockPubScreen("Workbench");
  179.             if (Scr == NULL) {MakeReq("Couldn't lock Workbench Screen!",NULL,"Where is it?"); return(1L);}
  180.             screenwidth = Scr->Width;
  181.             screenheight = Scr->Height;
  182.             break;
  183.         }
  184.         
  185.     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
  186.         return( 2L );
  187.  
  188.     return( 0L );
  189. }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197. void CloseDownScreen( void )
  198. {
  199.     if ( VisualInfo ) 
  200.         {
  201.         FreeVisualInfo( VisualInfo );
  202.         VisualInfo = NULL;
  203.         }
  204.  
  205.     switch(screentype)
  206.         {
  207.         case USE_CUSTOMSCREEN:
  208.             CloseScreen( Scr );
  209.             Scr = NULL;
  210.             break;
  211.         case USE_PUBSCREEN:
  212.             UnlockPubScreen(NULL,Scr);
  213.             break;
  214.         case USE_WBSCREEN:
  215.             UnlockPubScreen(NULL,Scr);
  216.             break;
  217.         }
  218.     
  219.     screenisopen = 0;        
  220. }    
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. int HandlemgetIDCMP( void )
  231. {
  232.     struct IntuiMessage    *m;
  233.     struct MenuItem        *n;
  234.     int            (*func)();
  235.     BOOL            running = TRUE;
  236.     WORD        wtop = -1 , wleft = -1, wheight = -1 , wwidth= -1;
  237.     struct NewGadget ng;
  238.     struct Gadget    *g;
  239.  
  240.     while( m = GT_GetIMsg( mgetWnd->UserPort )) {
  241.  
  242.         CopyMem(( char * )m, ( char * )&mgetMsg, (long)sizeof( struct IntuiMessage ));
  243.         lastcode = m->Code;
  244.         
  245.         GT_ReplyIMsg( m );
  246.     
  247.         switch ( mgetMsg.Class ) {
  248.  
  249.             case    IDCMP_REFRESHWINDOW:
  250.                 GT_BeginRefresh( mgetWnd );
  251.                 GT_EndRefresh( mgetWnd, TRUE );
  252.                 break;
  253.  
  254.             case IDCMP_NEWSIZE:
  255.                 windowtop = mgetWnd->TopEdge;
  256.                 windowleft = mgetWnd->LeftEdge;
  257.                 windowheight = mgetWnd->Height;
  258.                 windowwidth = mgetWnd->Width;
  259.                 
  260.                 RemoveGList(mgetWnd, mgetGList, -1);
  261.                 FreeGadgets(mgetGList);
  262.                 
  263.                 EraseRect(mgetWnd->RPort,mgetWnd->BorderLeft, mgetWnd->BorderTop,
  264.                             mgetWnd->Width - mgetWnd->BorderRight - 1,
  265.                             mgetWnd->Height - mgetWnd->BorderBottom - 1);
  266.                             
  267.                 if (SetupGadgets(g, &ng) == 2L) 
  268.                     {
  269.                     MakeReq("ListView Gadget Setup Error",NULL,"I wish Jeremy would debug better");
  270.                     Cleanup();
  271.                     exit(10);
  272.                     }
  273.                 AddGList(mgetWnd, mgetGList, -1, -1, NULL);
  274.                 RefreshGList(mgetGList, mgetWnd, NULL, -1);
  275.                         
  276.                 GT_RefreshWindow(mgetWnd, NULL);
  277.                 RefreshWindowFrame(mgetWnd);
  278.                 
  279.                 ChangeWindowTitle();                
  280.                 
  281.                 
  282.                 GT_SetGadgetAttrs((struct Gadget *) mgetGadgets[0], mgetWnd, NULL, GTLV_Labels, filelist, TAG_END); 
  283.                 GT_SetGadgetAttrs((struct Gadget *) mgetGadgets[1], mgetWnd, NULL, GTLV_Labels, getlist, TAG_END); 
  284.                 break;
  285.                 
  286.             case    IDCMP_CLOSEWINDOW:
  287.                 running = mgetCloseWindow();
  288.                 break;
  289.  
  290.             case    IDCMP_GADGETUP:
  291.             case    IDCMP_GADGETDOWN:
  292.                 func = ( void * )(( struct Gadget * )mgetMsg.IAddress )->UserData;
  293.                 running = func();
  294.                 break;
  295.  
  296.             case    IDCMP_MENUPICK:
  297.                 while( mgetMsg.Code != MENUNULL ) {
  298.                     n = ItemAddress( mgetMenus, mgetMsg.Code );
  299.                     func = (void *)(GTMENUITEM_USERDATA( n ));
  300.                     running = func();
  301.                     mgetMsg.Code = n->NextSelect;
  302.                 }
  303.                 break;
  304.         }
  305.     }
  306.     return( running );
  307. }
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317. int SetupGadgets(struct Gadget *gadlist, struct NewGadget *ng)
  318. {
  319.  UWORD        lc, tc;
  320.  UWORD        offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  321.  UWORD        wheight = windowheight - offy;
  322.  UWORD        wwidth  = windowwidth  - offx;
  323.  UWORD        topedge[2], height[2];
  324.  BYTE           bSizeGadHeight = 8;        /* This shouldn't be hardcoded, but how to find out when the window is closed??? */
  325.  struct List      *thislist = NULL; 
  326.           
  327.  topedge[0]    = offy;
  328.  height[0]     = ((int) (.7 * wheight));
  329.  topedge[1]    = topedge[0] + height[0] + 1;
  330.  height[1]     = windowheight - topedge[1] - bSizeGadHeight - 2;
  331.  
  332.     nTopListTop = topedge[0];
  333.     nTopListHeight = height[0];
  334.     
  335.     /* Put in correct font */
  336.     listfont.ta_Name  = sListFontName;
  337.     if (nListFontSize > 0) listfont.ta_YSize = nListFontSize; else listfont.ta_YSize = 12;
  338.     /* a reasonable default, hopefully! */
  339.     listfontdata = OpenDiskFont(&listfont);    
  340.     if (listfontdata == NULL)
  341.      {
  342.          /* load system default font */
  343.          
  344.         listfontdata = GraphicsBase->DefaultFont;
  345.         listfont.ta_YSize = GraphicsBase->DefaultFont->tf_YSize; 
  346.         if (strlen(sListFontName) > 0) 
  347.         {
  348.             MakeReq("Couldn't find specified font, Sorry!",NULL,"Um, Ok");
  349.             strncpy(sListFontName,NUL,1);
  350.         }
  351.      }
  352.            
  353.     if ( ! ( gadlist = CreateContext( &mgetGList )))
  354.         return( 1L );
  355.  
  356.     for( lc = 0, tc = 0; lc < mget_CNT; lc++ ) 
  357.         {
  358.         
  359.         if (lc == 1) 
  360.             {
  361.             thislist = getlist;
  362.             }
  363.             else 
  364.             {
  365.             thislist = filelist;
  366.             }
  367.  
  368.             
  369.         CopyMem((char * )&mgetNGad[ lc ], (char * )ng, (long)sizeof( struct NewGadget ));
  370.  
  371.         ng->ng_VisualInfo = VisualInfo;
  372.         ng->ng_TextAttr   = &listfont;
  373.         ng->ng_LeftEdge   = offx;
  374.       ng->ng_TopEdge    = topedge[lc];
  375.         ng->ng_Width      = wwidth - offx;
  376.       ng->ng_Height     = height[lc];    
  377.        ng->ng_GadgetText = NULL;
  378.         ng->ng_Flags        = NULL;
  379.         ng->ng_GadgetID   = lc + 50;
  380.  
  381.         mgetGadgets[ lc ] = gadlist = CreateGadget(LISTVIEW_KIND, gadlist, ng, GTLV_Top, 0, TAG_END);
  382.         
  383.         while( mgetGTags[ tc ] ) tc += 2;
  384.         tc++;
  385.  
  386.         if ( NOT gadlist)
  387.         {
  388.             return( 2L );
  389.         }
  390.     }
  391. }
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401. int OpenmgetWindow( void)
  402. {
  403.     struct NewGadget ng;
  404.     struct Gadget    *g;
  405.     int titleheight = (Scr->WBorTop + Scr->RastPort.TxHeight + 1);
  406.     int nMinHeight;
  407.     
  408.     if (nListFontSize == 0) nListFontSize = GraphicsBase->DefaultFont->tf_YSize;    /* get default setting */
  409.     
  410.     nMinHeight = (8 * (nListFontSize + 2));
  411.     if (nMinHeight < 90) nMinHeight = 90;
  412.     nMinHeight += titleheight;
  413.   
  414.     if ((windowwidth <= 0)||(windowwidth > screenwidth)) windowwidth  = screenwidth;
  415.     if (windowheight < nMinHeight) windowheight = nMinHeight;
  416.     
  417.     if ((windowheight <= 0)||(windowheight > screenheight)) windowheight = screenheight - titleheight;
  418.             
  419.     if ((windowleft <= 0)||(windowleft > screenwidth))        windowleft   = 0;
  420.     if ((windowleft+windowwidth) > screenwidth)    windowwidth -= windowleft;
  421.     if ((windowtop <= 0)||(windowtop > screenheight))       windowtop    = titleheight;
  422.     if ((windowtop+windowheight) > screenheight) windowheight -= windowtop;
  423.         
  424.     if ((windowwidth <= 0)||(windowwidth > screenwidth))    
  425.         {
  426.         windowwidth  = screenwidth;
  427.         windowleft = 0;
  428.         }
  429.         
  430.     if ((windowheight <= 0)||(windowheight > screenheight)) 
  431.         {
  432.         windowheight = screenheight - titleheight;
  433.         windowtop = titleheight;
  434.         }
  435.         
  436.     
  437.     if (SetupGadgets(g, &ng) == 2L) return(2L);    
  438.     
  439.     if ( ! ( mgetMenus = CreateMenus( mgetNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
  440.         return( 3L );
  441.     
  442.     LayoutMenus( mgetMenus, VisualInfo, TAG_DONE );    
  443.         
  444.     switch (screentype)
  445.         {
  446.         case USE_PUBSCREEN:
  447.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  448.                 WA_Left,        windowleft,
  449.                 WA_Top,        windowtop,
  450.                 WA_Width,         windowwidth,
  451.                 WA_Height,    windowheight,
  452.                 WA_PubScreen,    Scr,
  453.                 WA_PubScreenFallBack, TRUE,
  454.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  455.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  456.                 WA_Gadgets,    mgetGList,
  457.                 WA_Title,         windowtitle,
  458.                 WA_ScreenTitle,pnamestring,
  459.                 WA_MinWidth,    155,
  460.                 WA_MinHeight,    nMinHeight,
  461.                 WA_MaxWidth,    -1,
  462.                 WA_MaxHeight,    -1,
  463.                 TAG_DONE )))    
  464.                     return( 4L );
  465.             break;
  466.             
  467.         case USE_CUSTOMSCREEN:
  468.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  469.                 WA_Left,        windowleft,
  470.                 WA_Top,        windowtop,
  471.                 WA_Width,         windowwidth,
  472.                 WA_Height,    windowheight,
  473.                 WA_CustomScreen,    Scr,
  474.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  475.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  476.                 WA_Gadgets,    mgetGList,
  477.                 WA_Title,         windowtitle,
  478.                 WA_ScreenTitle,pnamestring,
  479.                 WA_MinWidth,    155,
  480.                 WA_MinHeight,    nMinHeight,
  481.                 WA_MaxWidth,    -1,
  482.                 WA_MaxHeight,    -1,
  483.                 TAG_DONE )))    
  484.                     return( 4L );
  485.             break;
  486.             
  487.         case USE_WBSCREEN:
  488.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  489.                 WA_Left,        windowleft,
  490.                 WA_Top,        windowtop,
  491.                 WA_Width,         windowwidth,
  492.                 WA_Height,    windowheight,
  493.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  494.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  495.                 WA_Gadgets,    mgetGList,
  496.                 WA_Title,         windowtitle,
  497.                 WA_ScreenTitle,pnamestring,
  498.                 WA_MinWidth,    155,
  499.                 WA_MinHeight,    nMinHeight,
  500.                 WA_MaxWidth,    -1,
  501.                 WA_MaxHeight,    -1,
  502.                 TAG_DONE )))    
  503.                     return( 4L );
  504.                     
  505.             if (appwindow == 1)
  506.                 {
  507.                 awport = CreateMsgPort();
  508.                 if (awport == NULL) 
  509.                     {
  510.                     appwindow = 0;
  511.                     return(4L);
  512.                     }
  513.  
  514.                 appwin = AddAppWindow(1, 0, mgetWnd, awport, NULL);
  515.                 
  516.                 if (appwin == NULL)
  517.                     {appwindow = 0;}
  518.                     else
  519.                     appwinsig = 1L << awport->mp_SigBit;
  520.                 }
  521.                 
  522.             break;
  523.         }    
  524.  
  525.     TurnOnAllMenuItems(mgetMenus);
  526.     SetMenuStrip( mgetWnd, mgetMenus ); 
  527.     GT_RefreshWindow( mgetWnd, NULL );
  528.  
  529. return( 0L );
  530. }
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538. void ClosemgetWindow( void )
  539. {
  540.     if ( mgetMenus      ) {
  541.         ClearMenuStrip( mgetWnd );
  542.         FreeMenus( mgetMenus );
  543.         mgetMenus = NULL;    }
  544.  
  545.     if ( findwindow     ) { 
  546.          CloseWindow( findwindow );
  547.          FreeGadgets(findgadlist);
  548.          FreeVisualInfo(findvi);
  549.          findwindow = NULL;
  550.          }
  551.      
  552.      if (appwin) {
  553.          RemoveAppWindow(appwin);
  554.          
  555.          /* throw out any leftover messages */
  556.          while(amsg = (struct AppMessage *) GetMsg(awport))
  557.                  ReplyMsg((struct Message *) amsg);
  558.          DeleteMsgPort(awport);
  559.          }
  560.         
  561.     if ( mgetWnd        ) {
  562.         CloseWindow( mgetWnd );
  563.         windowisopen = 0;
  564.         mgetWnd = NULL;
  565.         }
  566.  
  567.     if ( mgetGList      ) {
  568.         FreeGadgets( mgetGList );
  569.         mgetGList = NULL;
  570.         }
  571. }
  572.  
  573.  
  574. #endif
  575.  
  576.